package com.msv.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

/**
 * create by yongli on 2021-04-24 17:59
 */
@Configuration
public class SpringUtil implements ApplicationContextAware {

    private static ApplicationContext app = null;

    public static <T> T getBean(Class<T> t) {
        return app.getBean(t);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        app = applicationContext;
    }
}
